<?php
/**
 * Class for managing message threads
 * 
 * @package message
 */
class Zend_Jabber_Message_Thread {
    /**
     * List(dictionary) of oppended message threads
     * 
     * @var array
     */
    private static $openedThreads = array();
    
    /**
     * Message thread identified
     * 
     * @var string 
     */
    private $string;
    
    /**
     * Create new message thread
     */
    public function __construct() {
        $this->string = md5(time());
        
        self::$openedThreads[$this->toString()] = $this;
    }
    
    /**
     * Search for message thread by identifier stirng
     * 
     * @param string $string Identifier string
     */
    public static function searchByString($string) {
        return isset(self::$openedThreads[$string]) ? self::$openedThreads[$string] : new self();
    }
    
    /**
     * Convert message thread to string
     */
    public function toString() {
        return $this->string;
    }
}
?> 